﻿using Breeze.ContextProvider;
using Breeze.ContextProvider.EF6;
using Breeze.WebApi2;
using Newtonsoft.Json.Linq;
using RecruitmentPage.Models;
using RecruitmentPage.Models.RPModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace RecruitmentPage.Controllers
{
    [BreezeController]
    public class DataController : ApiController
    {
        readonly EFContextProvider<RPContext> _contextProvider =
            new EFContextProvider<RPContext>();

        [HttpGet]
        public string Metadata()
        {
            return _contextProvider.Metadata();
        }

        [HttpPost]
        public SaveResult SaveChanges(JObject saveBundle)
        {
            return _contextProvider.SaveChanges(saveBundle);
        }

        [HttpGet]
        public IQueryable<Job> Jobs()
        {
            return _contextProvider.Context.Set<Job>().Include("Location.Parent").Include("Industry").Include("PersonalInfor").Include("Currency");
        }
        [HttpGet]
        public IQueryable<Currency> Currencies()
        {
            return _contextProvider.Context.Set<Currency>();
        }
        [HttpGet]
        public IQueryable<Industry> Industries()
        {
            return _contextProvider.Context.Set<Industry>().Include("Children");
        }
        [HttpGet]
        public IQueryable<Location> Locations()
        {
            return _contextProvider.Context.Set<Location>().Include("Children.Children").Include("Parent");
        }
        [HttpGet]
        public IQueryable<Account> Accounts()
        {
            return _contextProvider.Context.Set<Account>().Include("PersonalInfor.CareerExpect").Include("Role.RoleMenu.Menu").Include("PersonalInfor.Education").Include("PersonalInfor.WorkExperience");
        }

        [HttpGet]
        public IQueryable<ApplyJob> ApplyJobs()
        {
            return _contextProvider.Context.Set<ApplyJob>().Include("Job").Include("PersonalInfor");
        }

        [HttpGet]
        public IQueryable<PersonalInfor> PersonalInfors()
        {
            return _contextProvider.Context.Set<PersonalInfor>();
        }

        [HttpGet]
        public IQueryable<Role> Roles()
        {
            return _contextProvider.Context.Set<Role>();
        }

        [HttpGet]
        public IQueryable<Menu> Menus()
        {
            return _contextProvider.Context.Set<Menu>();
        }
        [HttpGet]
        public IQueryable<JobType> JobTypes()
        {
            return _contextProvider.Context.Set<JobType>();
        }
        [HttpGet]
        public IQueryable<JobLevel> JobLevels()
        {
            return _contextProvider.Context.Set<JobLevel>();
        }

        [HttpGet]
        public IQueryable<University> Universitys()
        {
            return _contextProvider.Context.Set<University>();
        }
        [HttpGet]
        public IQueryable<Degree> Degrees()
        {
            return _contextProvider.Context.Set<Degree>();
        }
        [HttpGet]
        public IQueryable<KindofDegree> KindofDegrees()
        {
            return _contextProvider.Context.Set<KindofDegree>();
        }
        [HttpGet]
        public IQueryable<Major> Majors()
        {
            return _contextProvider.Context.Set<Major>();
        }
        [HttpGet]
        public IQueryable<CareerExpect> CareerExpects()
        {
            return _contextProvider.Context.Set<CareerExpect>().Include("Industry").Include("JobLevel");
        }

        [HttpGet]
        public IQueryable<Education> Educations()
        {
            return _contextProvider.Context.Set<Education>().Include("Major").Include("University").Include("Degree").Include("KindofDegree");
        }

        [HttpGet]
        public IQueryable<WorkExperience> WorkExperiences()
        {
            return _contextProvider.Context.Set<WorkExperience>().Include("Location").Include("JobLevel").Include("Industry");
        }

    }




}
